package cn.csc.module.product.controller.app.brand;

import cn.csc.framework.common.pojo.CommonResult;
import cn.csc.framework.common.pojo.PageResult;
import cn.csc.module.product.controller.admin.brand.vo.BrandRespVO;
import cn.csc.module.product.controller.app.brand.vo.AppBrandPageReqVO;
import cn.csc.module.product.controller.app.brand.vo.AppBrandRespVO;
import cn.csc.module.product.convert.brand.BrandConvert;
import cn.csc.module.product.dal.dataobject.brand.BrandDO;
import cn.csc.module.product.service.brand.BrandService;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigInteger;
import java.util.List;

import static cn.csc.framework.common.pojo.CommonResult.success;

/**
 * @author liuchuang
 * @version 1.0
 * @date 2024/1/4 15:49
 * @modify
 */
@Api(tags = "用户 APP - 品牌信息")
@RestController("appBrandController")
@RequestMapping("/product/brand")
@Validated
@Slf4j
@Setter
public class AppBrandController {

    @Autowired
    private BrandService brandService;


    @GetMapping("/page")
    @Operation(summary = "获取品牌信息列表" , description = "分页获取品牌信息列表")
    public CommonResult<PageResult<BrandRespVO>> page(AppBrandPageReqVO reqVO) {
        PageResult<BrandDO> brandPage = brandService.getBrandPage(reqVO);
        return success(BrandConvert.INSTANCE.convertPage(brandPage));
    }

    @GetMapping("/list_by_category")
    @Operation(summary = "分类-推荐品牌信息列表" , description = "分类-推荐品牌信息列表")
    public CommonResult<List<AppBrandRespVO>> getTopBrandList(BigInteger categoryId) {
        List<AppBrandRespVO> brandPage = brandService.listByCategory(categoryId);
        return CommonResult.success(brandPage);
    }

}
